/*
 * @Description: emp控制层
 * @Author: liuzl
 * @Date: 2024-12-04 14:53:03
 * @LastEditors: liuzl
 * @LastEditTime: 2024-12-04 15:17:50
 */
package com.briup.web;

import com.briup.pojo.Emp;
import com.briup.service.IEmpService;
import com.briup.service.impl.EmpServiceImpl;
import com.briup.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/emps")//这里不需要加@Component注解，因为Spring已经扫描到这个类了
public class EmpController {
    //获取业务层对象
//    private IEmpService empService = new EmpServiceImpl();
    @Autowired
    private IEmpService empService;
    @GetMapping("/{id}")
    public Result getById(@PathVariable Integer id){
//        通过业务层对象处理业务逻辑
        Emp emp = empService.getEmpById(id);
        return Result.success(emp);
    }

}
